package com.cheyun.netsalev3.view.stockquery

import android.content.Intent
import androidx.fragment.app.Fragment
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.adapter.HomePageAdapter
import com.cheyun.netsalev3.databinding.StockQueryActivityBinding
import com.cheyun.netsalev3.utils.BaseActivity
import com.cheyun.netsalev3.view.StockSearchActivity

class StockQueryActivity : BaseActivity<StockQueryActivityBinding>() {


    override fun initContentView(): Int {
        return R.layout.stock_query_activity
    }

    var titles = arrayListOf("在库", "预定", "在途", "出库")
    var states = arrayListOf("inlib", "resv","otw", "outbd")
    private var listFragmet = ArrayList<Fragment>()


    override fun initData() {
    }

//    override fun initViewModel(): ViewModel? {
//        if (state.isNotEmpty()) {
//            hashMap["nkey"] = "index"
//            hashMap["ckey"] = state
//        }
//        val factory = InjectorUtils.getStockQueryListViewModelFactory(hashMap)
//        return ViewModelProviders.of(this, factory).get(StockQueryListViewModel::class.java)
//    }

    override fun initView() {
        for (i in titles.indices) {
            listFragmet.add(StockQueryListFragment.newInstance(states[i]))
        }
        val pagerAdapter = HomePageAdapter(supportFragmentManager, listFragmet)
        pagerAdapter.titles = titles
        binding.viewPager.offscreenPageLimit = 4
        binding.viewPager.adapter = pagerAdapter
        binding.tabLayout.setupWithViewPager(binding.viewPager)
        binding.headView.rightImg?.setImageResource(R.drawable.d01_6_kc_search)
        binding.headView.rightImg?.setOnClickListener {
            var intent = Intent(this, StockSearchActivity::class.java)
            startActivity(intent)
        }


    }

}
